//
//  HallViewController.m
//  网易彩票
//
//  Created by zhoup on 16/5/29.
//  Copyright © 2016年 zhoup. All rights reserved.
//

#import "HallViewController.h"

@interface HallViewController ()

/**
 遮盖
 */
@property(nonatomic,strong) UIView *coverView;


@property(nonatomic,strong) UIImageView *advImageView;
@end

@implementation HallViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
//     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"test" style:UIBarButtonItemStylePlain target:nil action:nil];
//    
//     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"test1" style:UIBarButtonItemStylePlain target:nil action:nil];
}



#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

#pragma mark -
- (IBAction)leftBarButtonClicked:(id)sender {
    
    UIView *coverView = [[UIView alloc]init];
    coverView.frame = [UIScreen mainScreen].bounds;
    coverView.alpha = 0.5;
    [coverView setBackgroundColor:[UIColor blackColor]];
    self.coverView = coverView;
    [self.tabBarController.view addSubview:coverView];
    
    
    UIImageView *advImageView = [[UIImageView alloc]init];
    advImageView.image = [UIImage imageNamed:@"cover"];
    [advImageView sizeToFit];
    advImageView.center =  self.view.center;
    self.advImageView = advImageView;
    advImageView.userInteractionEnabled = YES;
    [self.tabBarController.view addSubview:advImageView];
    
    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [closeBtn setBackgroundColor:[UIColor whiteColor]];
    [closeBtn setImage:[UIImage imageNamed:@"ArenaHall_Close"] forState:UIControlStateNormal];
    
    closeBtn.width = 24;
    closeBtn.x = advImageView.width - closeBtn.width;
    closeBtn.y = 0;
    closeBtn.height = 24;
    
    [closeBtn addTarget:self action:@selector(closeBtnClicked:) forControlEvents:UIControlEventTouchUpInside];

    [advImageView addSubview:closeBtn];
    
}

#pragma mark - closeBtnClicked
-(void)closeBtnClicked:(UIButton *)sender
{
    NSLog(@"%s",__func__);
    
    [UIView animateWithDuration:1 animations:^{
        self.coverView.alpha = 0;
        self.advImageView.alpha = 0;
        
    } completion:^(BOOL finished) {
        
        [self.coverView removeFromSuperview];
        
        [self.advImageView removeFromSuperview];

    }];
}


@end
